/**
 * 初始化医嘱执行记录详情对话框
 */
var CdcOrdexecInfoDlg = {
    validateFields: {
    	xcode: {
            validators: {
                notEmpty: {
                    message: '索引码不能为空'
                }
            }
        },
    	episodeId: {
            validators: {
                notEmpty: {
                    message: '就诊记录不能为空'
                }
            }
        },
    	orderMastId: {
            validators: {
                notEmpty: {
                    message: '医嘱项不能为空'
                }
            }
        },
    	busOrderStatusId: {
            validators: {
                notEmpty: {
                    message: '状态不能为空'
                }
            }
        },
    	orderDate: {
            validators: {
                notEmpty: {
                    message: '开医嘱日期不能为空'
                }
            }
        },
    	orderLocId: {
            validators: {
                notEmpty: {
                    message: '开医嘱科室不能为空'
                }
            }
        },
    	recLocId: {
            validators: {
                notEmpty: {
                    message: '接收科室不能为空'
                }
            }
        },
    	startDate: {
            validators: {
                notEmpty: {
                    message: '开始日期不能为空'
                }
            }
        },
    	endDate: {
            validators: {
                notEmpty: {
                    message: '停止日期不能为空'
                }
            }
        },
    	busOrderInstrucId: {
            validators: {
                notEmpty: {
                    message: '给药途径不能为空'
                }
            }
        },
    	doseQty: {
            validators: {
                notEmpty: {
                    message: '单次剂量不能为空'
                }
            }
        },
    	busOrderUnitId: {
            validators: {
                notEmpty: {
                    message: '剂量单位不能为空'
                }
            }
        },
    	busOrderFreqId: {
            validators: {
                notEmpty: {
                    message: '频次不能为空'
                }
            }
        },
    	isAnti: {
            validators: {
                notEmpty: {
                    message: '是否抗生素不能为空'
                }
            }
        },
    	dataId: {
            validators: {
                notEmpty: {
                    message: '业务数据类型不能为空'
                }
            }
        },
    	isActive: {
            validators: {
                notEmpty: {
                    message: '是否有效不能为空'
                }
            }
        },
    }
};


/**
 * 关闭此对话框
 */
CdcOrdexecInfoDlg.close = function() {
    parent.layer.close(parent.layer.getFrameIndex(window.name)); //先得到当前iframe层的索引,再执行关闭   
}

/**
 * 验证数据是否为空
 */
CdcOrdexecInfoDlg.validate = function () {
    $('#cdcOrdexecInfoForm').data("bootstrapValidator").resetForm();
    $('#cdcOrdexecInfoForm').bootstrapValidator('validate');
    return $("#cdcOrdexecInfoForm").data('bootstrapValidator').isValid();
}

/**
 * 提交新增
 */
CdcOrdexecInfoDlg.addSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('cdcOrdexecInfoForm',Sys.backendPath + "/cdc/cdcordexec/add",function(res) {
        Sys.success(res.message);
    	window.parent.CdcOrdexec.table.refresh();
        CdcOrdexecInfoDlg.close();
    });
}

/**
 * 提交修改
 */
CdcOrdexecInfoDlg.editSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('cdcOrdexecInfoForm',Sys.backendPath + "/cdc/cdcordexec/update",function(res) {
        Sys.success(res.message);
    	window.parent.CdcOrdexec.table.refresh();
        CdcOrdexecInfoDlg.close();
    });
}

$(function() {
	Sys.initValidator("cdcOrdexecInfoForm", CdcOrdexecInfoDlg.validateFields);
});
